package personnel.department.pages.widgets;

import java.lang.reflect.Field;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import personnel.department.dao.entity.UniqueObject;

public class TextWidget extends AbstractWidget<String> {

	private String title;
	private Composite parent;
	private Label label;
	private Text text;
	private Field field;

	public TextWidget(Composite parent,  String title, Field field) {
		super(field);
		this.parent = parent;
		this.title = title;
		create();
	}

	@Override
	protected void create() {
		label = new Label(parent, SWT.NONE);
		label.setText(title);
		text = new Text(parent, SWT.BORDER);
		text.setLayoutData(new GridData(150, 15));
		text.addListener(SWT.Modify, event -> modify());
		super.create();
	}
	
	@Override
	public void setValue(String value) {
		text.setText(value);
		modify();
	}
	
	@Override
	public String getValue() {
		return text.getText();
	}

	@Override
	protected Control getWidget() {
		return text;
	}
	

}
